package com.eve.eplus.sns;

import java.util.ArrayList;
import java.util.HashMap;
import android.os.Handler;
import android.os.Message;

import com.eve.eplus.common.adapter.HomeContentAdapter;
import com.eve.eplus.common.app.Constants;
import com.eve.eplus.sns.weibo.WeiboAPIGather;

/**
 * TimeLine分发
 * 
 * @author norsie
 * @create 13-01-12
 */

public class TimeLineProvider
{
    private HashMap<String, String> mAccountInfo;
    private Handler mHandler;

    // private StatusesAPI statusesAPI=new
    // StatusesAPI(BaseApplication.sinaAccessToken);

    public TimeLineProvider(HashMap<String, String> accountInfo, Handler handler)
    {
        this.mAccountInfo = accountInfo;
        this.mHandler = handler;
    }

     /**
      * 获取微博信息
      * @param Pages 页码
      */
    public void getTimeline(int Pages) {
        if(mAccountInfo.get(Constants.SNSTYPE).equals(Constants.SNSTYPE_SINA)){
            new WeiboAPIGather(mAccountInfo, handler).getTimeline(Pages);
        }else if(mAccountInfo.get(Constants.SNSTYPE).equals(Constants.SNSTYPE_TENCENT)){
        
        }else if(mAccountInfo.get(Constants.SNSTYPE).equals(Constants.SNSTYPE_RENREN)){
            
        }
    }
    
    /**
     * 获取微博信息-提供json
     * @param json json解析
     */
   public void getTimeline(String json) {
       if(mAccountInfo.get(Constants.SNSTYPE).equals(Constants.SNSTYPE_SINA)){
           new WeiboAPIGather(mAccountInfo, handler).getTimeline(json);
       }else if(mAccountInfo.get(Constants.SNSTYPE).equals(Constants.SNSTYPE_TENCENT)){
       
       }else if(mAccountInfo.get(Constants.SNSTYPE).equals(Constants.SNSTYPE_RENREN)){
           
       }
   }
    
    /**
     * 获取早些时候的微博
     * @param arg
     */
    public void getTimelineMore(String arg) {
        if(mAccountInfo.get(Constants.SNSTYPE).equals(Constants.SNSTYPE_SINA)){
            new WeiboAPIGather(mAccountInfo, handler).getTimelineMore(Long.parseLong(arg));
        }else if(mAccountInfo.get(Constants.SNSTYPE).equals(Constants.SNSTYPE_TENCENT)){
        
        }else if(mAccountInfo.get(Constants.SNSTYPE).equals(Constants.SNSTYPE_RENREN)){
            
        }
    }
    
    private Handler handler = new Handler() {

        public void handleMessage(Message msg)
        {
            switch (msg.what)
            {
                case Constants.MSG_WEIBO_TIMELINE_OK:
                    Message message = new Message();  
                    message.what = Constants.MSG_TIMELINE_OK;  
                    message.obj=msg.obj;
                    mHandler.sendMessage(message);
                    break;
            }
        };
    };
}
